﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ESF.MUP.BasePlatform.DbRepositories;
using ESF.MUP.BasePlatform.DbRepository.MSSQL.Model;

namespace ESF.MUP.BasePlatform.DbRepository.MSSQL
{
    public class SqlContext : UnitOfWork
    {

        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="connection"></param>
        public SqlContext(System.Data.Common.DbConnection connection)
            : base(connection)
        {
        }

        public SqlContext()
            : base(new System.Data.SqlClient.SqlConnection(@"data source=.\ESF;initial catalog=ESF_MUP;integrated security=True"))
        {

        }

        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Configurations.Add(new ApplicationModelBuilder());

            EnvironmentModelBuilder.ConfigureDatabase(modelBuilder);
            ApplicationInstanceModelBuilder.ConfigureDatabase(modelBuilder);
            ComponentsModelBuilder.ConfigureDatabase(modelBuilder);            
            EndpointModelBuilder.ConfigureDatabase(modelBuilder);

        }
    }
}
